from rest_framework import serializers
from apps.product.report.models import ReportModel
from utils.common import date_format


class ReportModelSerializer(serializers.ModelSerializer):

    class Meta:
        model = ReportModel
        exclude = ["is_delete", "update_time"]
        extra_kwargs = {
            "name": {
                "min_length": 2,
                "max_length": 200,
                "error_messages": {
                    "min_length": "测试报告名称长度为 2-200 个字符！",
                    "max_length": "测试报告名称长度为 2-200 个字符！"
                }
            },
            "create_time": {
                "read_only": True,
                "format": date_format()
            }
        }
